package io.renren.modules.wx.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.wx.dao.NoteDao;
import io.renren.modules.wx.entity.NoteEntity;
import io.renren.modules.wx.service.NoteService;


@Service("noteService")
public class NoteServiceImpl extends ServiceImpl<NoteDao, NoteEntity> implements NoteService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<NoteEntity> page = this.page(
                new Query<NoteEntity>().getPage(params),
                new QueryWrapper<NoteEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<NoteEntity> getNotesByStudentId(Integer studentId) {
        List<NoteEntity> list = baseMapper.selectList(new QueryWrapper<NoteEntity>().eq("student_id",studentId));
        return list;
    }

    @Override
    public void deleteNote(NoteEntity noteEntity) {
        Integer id = noteEntity.getNoteId();
        baseMapper.deleteById(id);
    }
}
